package com.project.xy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.common.entity.PageVo;
import com.project.xy.entity.DFile;
import com.project.xy.entity.DesignModule;
import com.project.xy.entity.ProSearch;
import com.project.xy.mapper.DFileMapper;
import com.project.xy.service.DFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class DFileServiceImpl implements DFileService {

    @Autowired
    private DFileMapper dFileMapper;

    @Override
    public PageVo<DFile> queryRegisterAll(Map<String, String> map) {

        Integer pageNum = Integer.valueOf(map.get("pageNum"));
        Integer pageSize= Integer.valueOf(map.get("pageSize"));

        PageHelper.startPage(pageNum,pageSize);
        List<DFile> dFileList = dFileMapper.queryRegisterAll();

        PageInfo<DFile> pageInfo = new PageInfo<>(dFileList);

        PageVo<DFile> pageVo = new PageVo<>();
        pageVo.setTotal(pageInfo.getTotal());
        pageVo.setRows(pageInfo.getList());

        return pageVo;
    }

    @Override
    public PageVo<DFile> queryOutRegisterAll(Map<String, String> map) {

        Integer pageNum = Integer.valueOf(map.get("pageNum"));
        Integer pageSize = Integer.valueOf(map.get("pageSize"));

        PageHelper.startPage(pageNum,pageSize);

        PageInfo<DFile> pageInfo = new PageInfo<DFile>(dFileMapper.queryOutRegisterAll());

        PageVo<DFile> pageVo = new PageVo<DFile>();
        pageVo.setRows(pageInfo.getList());
        pageVo.setTotal(pageInfo.getTotal());

        return pageVo;
    }

    @Override
    public PageVo<DFile> SearchCheck_tagAndDesign_cell_tag(Map<String,String> map) {

        Integer pageNum = Integer.valueOf(map.get("pageNum"));
        Integer pageSize= Integer.valueOf(map.get("pageSize"));

        PageHelper.startPage(pageNum,pageSize);
        List<DFile> dFileList = dFileMapper.SearchCheck_tagAndDesign_cell_tag();

        PageInfo<DFile> pageInfo = new PageInfo<>(dFileList);

        PageVo<DFile> pageVo = new PageVo<>();
        pageVo.setTotal(pageInfo.getTotal());
        pageVo.setRows(pageInfo.getList());

        return pageVo;
    }

    @Override
    public int updateByProductIdSelective(DFile record) {
        return dFileMapper.updateByProductIdSelective(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer ID) {
        return dFileMapper.deleteByPrimaryKey(ID);
    }

    @Override
    public int insert(DFile record) {
        return dFileMapper.insert(record);
    }

    @Override
    public int insertSelective(DFile record) {
        return dFileMapper.insertSelective(record);
    }

    @Override
    public DFile selectByPrimaryKey(Integer ID) {
        return dFileMapper.selectByPrimaryKey(ID);
    }

    @Override
    public List<DFile> queryDFile() {
        return dFileMapper.queryDFile();
    }

    @Override
    public int updateByPrimaryKeySelective(DFile record) {
        return dFileMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(DFile record) {
        return dFileMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<DFile> selectByComState(String state) {
        return dFileMapper.selectByComState(state);
    }

    @Override
    public List<DFile> selectByCheck(ProSearch search) {
        return dFileMapper.selectByCheck(search);
    }

    @Override
    public List<DFile> selectByDelete(String tag) {
        return dFileMapper.selectByDelete(tag);
    }

    @Override
    public List<DFile> materielSelect(String type) {
        return dFileMapper.materielSelect(type);
    }

    @Override
    public DFile selectByPID(String pid) {
        return dFileMapper.selectByPID(pid);
    }

    @Override
    public PageVo<DFile> queryDFileCheckAllOk(Map<String,String> map) {
        Integer pageNum = Integer.valueOf(map.get("pageNum"));
        Integer pageSize= Integer.valueOf(map.get("pageSize"));

        PageHelper.startPage(pageNum,pageSize);
        List<DFile> dFileList = dFileMapper.queryDFileCheckAllOk();

        PageInfo<DFile> pageInfo = new PageInfo<>(dFileList);

        PageVo<DFile> pageVo = new PageVo<>();
        pageVo.setTotal(pageInfo.getTotal());
        pageVo.setRows(pageInfo.getList());

        return pageVo;
    }

    @Override
    public List<DFile> selectByDesignId(String states) {
        return dFileMapper.selectByDesignId(states);
    }
    @Override
    public DFile queryByProductId(String productId) {
        return dFileMapper.queryByProductId(productId);
    }

}
